<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gen="dummy-namespace-for-the-generated-xslt"
	exclude-result-prefixes="xsl">

	<xsl:namespace-alias stylesheet-prefix="gen"
		result-prefix="xsl" />

	<xsl:template match="rule">
		<html>
			<head>
				<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
				<title>Rule Editor</title>
				<link rel="stylesheet" type="text/css" href="../common.css" />
				<script type="text/javascript" src="/SecurityProject/RuleEditor.js">
				</script>
			</head>
			<body>
			<img src="../img/background.jpg" alt="" id="bg" />

			<div id="content">
			
				<h1>Edit Rule</h1>
			
				<form method="post" name="editRule" id="editRuleForm">
					<xsl:attribute name="action">../editRule/show?oldName=<xsl:value-of select="name"></xsl:value-of>
					</xsl:attribute>

					<div id="layout">

						<p>
							Rule Name:
							<br />
							<input type="text" id="ruleName" name="ruleName" size="40">
								<xsl:attribute name="value">
								<xsl:value-of select="name"></xsl:value-of>
							</xsl:attribute>
							</input>
						</p>

						<p>
							Description:
							<br />
							<textarea id="ruleDescription" name="ruleDescription"
								rows="3" cols="30">
								<xsl:value-of select="description"></xsl:value-of>
							</textarea>
						</p>
						
						<p>
							Rule Scope:
							<br />
							<select id="ruleScope" name="ruleScope">
								<option value="global">Global</option>
							<xsl:for-each select="files/file">
								<option>
									<xsl:attribute name="value">
										<xsl:value-of select="."></xsl:value-of>
									</xsl:attribute>
									<xsl:if test="../../ruleScope=.">
										<xsl:attribute name="selected">selected</xsl:attribute>
									</xsl:if>
									<xsl:value-of select="."></xsl:value-of>
								</option>
							</xsl:for-each>
							</select>
							
						</p>
						
						<p>
							Rule Type:
							<br />
							<input type="radio" name="ruleType" value="normal" onclick="javascript:showNormal()" >
								<xsl:if test="ruleType='normal'">
									<xsl:attribute name="checked">checked</xsl:attribute>
								</xsl:if>
							</input>
							Normal
							<br />
							<input type="radio" name="ruleType" value='custom' onclick="javascript:showCustom()" >
								<xsl:if test="ruleType='custom'">
									<xsl:attribute name="checked">checked</xsl:attribute>
								</xsl:if>
							</input>
							Custom
							<br />
						</p>

						<p>
							Filter Type:
							<br />
							<input type="radio" name="filterType" value="include">
								<xsl:if test="filterType='include'">
									<xsl:attribute name="checked">checked</xsl:attribute>
								</xsl:if>
							</input>
							Include
							<br />
							<input type="radio" name="filterType" value="exclude">
								<xsl:if test="filterType='exclude'">
									<xsl:attribute name="checked">checked</xsl:attribute>
								</xsl:if>
							</input>
							Exclude
							<br />
							<input type="radio" name="filterType" value='tagging'>
								<xsl:if test="filterType='tagging'">
									<xsl:attribute name="checked">checked</xsl:attribute>
								</xsl:if>
							</input>
							Tagging
							<br />
						</p>

						<p>
							Tag Name:
							<br />
							<input type="text" id="tagName" name="tagName" size="40">
								<xsl:attribute name="value">
									<xsl:value-of select="tagName"></xsl:value-of>
								</xsl:attribute>
							</input>
						</p>

						<div id="filtersSection">
						</div>
						
						<xsl:for-each select="filter">
							<script type="text/javascript">
								<xsl:value-of select='concat("addExistentFilter&#40;&#39;", fieldName, "&#39;&#44; &#39;", fieldMethod, "&#39;&#44; &#39;", expression, "&#39;&#41;&#59;")' />
							</script>
						</xsl:for-each>

						<div>
							<br />
							<input type="button" id="addFilterButton" name="addFilterButton" value="Add Filter" onclick="javascript:addFilter()" >
								<xsl:if test="ruleType='custom'">
									<xsl:attribute name="disabled">disabled</xsl:attribute>
								</xsl:if>
							</input>
						</div>
					</div>

			<!-- 	<p>
						Content:
						<br />
						<textarea id="ruleContent" name="ruleContent" >
							<xsl:if test="ruleType='normal'">
									<xsl:attribute name="disabled">disabled</xsl:attribute>
							</xsl:if>
						</textarea>
					</p> -->

					<p>
						<br />
						<br />
						<input type="submit" value="Save" />
					</p>

				</form>
			</div>
			
			</body>
		</html>


	</xsl:template>
</xsl:stylesheet>
